home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group92c.txt / 000034_icon-group-sender _Tue Oct 20 03:29:23 1992.msg < prev    next >
Internet Message Format  |  1993-01-04  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Sat, 24 Oct 1992 08:22:03 MST
  2. Date: 20 Oct 92 03:29:23 GMT
  3. From: uchinews!ellis!goer@speedy.wisc.edu  (Richard L. Goerwitz)
  4. Organization: University of Chicago Computing Organizations
  5. Subject: Re: How to skip comments?
  6. Message-Id: <1992Oct20.032923.20595@midway.uchicago.edu>
  7. References: <199210131550.AA16871@optima.cs.arizona.edu>
  8. Sender: icon-group-request@cs.arizona.edu
  9. To: icon-group@cs.arizona.edu
  10. Status: R
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12.  
  13. In article <199210131550.AA16871@optima.cs.arizona.edu> UBY@CU.NIH.GOV writes:
  14. >I have been trying to modify the concord.icn program from the Icon program
  15. >library to produce cross-reference tables for SAS programs, but I am stumped
  16. >about how to skip over comments.  Comments in the SAS language are of the form
  17. >/* ..... */.
  18.  
  19. What you want to do is perhaps to create a little machine with four states,
  20. and use it in place of read().  I don't know what sort of machine you are
  21. using, but assuming that lines terminate with \n, you might write something
  22. like what I have below.  Note that I haven't coded the routine to collect
  23. the text into lines.  It just suspends characters that don't constitute
  24. part of the comments:
  25.  
  26.  
  27. procedure stripped_sas()
  28.  
  29.     local c, state
  30.  
  31.     state := 0
  32.     every c := !(!&input || "\n") do {
  33.     case state of {
  34.         0      : {
  35.         if c == "/"
  36.         then state := 1
  37.         else suspend c
  38.         }
  39.         1      : {
  40.         if c == "*"
  41.         then state := 2
  42.         else {
  43.             suspend "/" | c
  44.             state := 0
  45.         }
  46.         }
  47.         2       : {    
  48.         if c == "*"
  49.         then state := 3
  50.         }
  51.         3       : {
  52.         if c == "/"
  53.         then state := 0
  54.         else state := 2
  55.         }
  56.     }
  57.     }
  58.  
  59. end
  60.  
  61.  
  62. -- 
  63.  
  64.    -Richard L. Goerwitz              goer%midway@uchicago.bitnet
  65.    goer@midway.uchicago.edu          rutgers!oddjob!ellis!goer
  66.